package week4.day26;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Scanner;

/**
 * @Author fengzihao
 * @Date 2024-05-10 20:12
 */
public class TestStudent {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        System.out.println("请输入学生信息，学生信息输入格式如下，姓名:年龄:成绩 ：");
        Scanner scanner = new Scanner(System.in);
        String studentInformation = scanner.nextLine();
        String[] stu = studentInformation.split(":");
        Class aClass = Class.forName("week4.day26.Student");
        Constructor constructor = aClass.getConstructor(String.class, int.class ,int.class);
        Object o = constructor.newInstance(stu[0], Integer.parseInt(stu[1]), Integer.parseInt(stu[2]));
        System.out.println(o);
    }

}
class Student{
    String name;
    int age;
    int score;

    public Student() {
    }

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}
